import View from './view';
import Form from './form';
import { getValidate } from '../utils';

import type { Rules } from 'async-validator/dist-types/interface';

export const rules: Rules = {
  borderRadius: [
    {
      type: 'number',
      required: true,
      message: '图片圆角不能为空',
    },
    {
      type: 'number',
      min: 0,
      message: '图片圆角不能小于0',
    },
  ],
};

export const PAD_STYLE = {
  withPad: {
    value: 'withPad',
    label: '有边距',
  },
  noPad: {
    value: 'noPad',
    label: '无边距',
  },
};

// initialValues分为content内容和样式，所有组件都包含两者，所以应该提到一个公共文件中去
const initialValues = {
  padStyle: PAD_STYLE.withPad.value, // 有无边距
  borderRadius: 6, // 图片圆角
  bgColor: '#ffff', // 背景颜色
  fontColor: '#333', // 文字颜色
  spacing: 0,
  options: {
    // 显示设置
    levelTag: {
      isShow: true,
      tagColor: '#e16d24',
    },
    levelProgress: {
      isShow: true,
      progressColor: '2c74ff',
    },
  },
};

export type UserInfoType = typeof initialValues;

export default {
  type: 'UserInfo',
  title: '个人信息',
  logo: 'https://saascdn.yumchina.com/crmyumc/764677033497722880/lotterydraw/202308221731363336.jpg',
  initialValues,
  view: View,
  form: Form,
  limit: 1,
  validate: getValidate(rules),
};
